#include "HeartbeatDetectionResponseModel.h"

using namespace MesModel;

void HeartbeatDetectionResponseModel::fromJson(const QJsonObject &json)
{
    factoryNo = json["factoryNo"].toString();
    transId = json["transId"].toString();
    eventTime = QDateTime::fromString(json["eventTime"].toString());
    resultCode = json["resultCode"].toString();
    resultMsg = json["resultMsg"].toString();

}

QJsonObject HeartbeatDetectionResponseModel::toJson() const
{
    QJsonObject json;
     int randomNumber = QRandomGenerator::global()->bounded(10000,100000);
    json["factoryNo"] = factoryNo;
    json["transId"] = QString("%1%2").arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmssSSS")).arg(randomNumber);
    json["eventTime"]=QDateTime::currentDateTime().toString("yyyy-mm-dd hh:mm:ss");
    json["resultCode"]=resultCode;
    json["resultMsg"]=resultMsg;
    return json;
}


HeartbeatDetectionResponseModel::HeartbeatDetectionResponseModel(QString factoryNo, QString transId, QDateTime eventTime, QString resultCode, QString resultMsg)
    :factoryNo(factoryNo),
    transId(transId),
    eventTime(eventTime),
    resultCode(resultCode),
    resultMsg(resultMsg)

{

}
